package MapClass;

import java.util.Objects;

public class Studnt {
    private String name;
    public Studnt(){}
    public Studnt(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

  /*  @Override//重写equals方法
    public boolean equals(Object obj) {
        if (obj == null||!(obj instanceof Studnt)) return false;
        if (obj == this) return true;
        Studnt s =(Studnt) obj;
       return this.name.equals(s.name);//相等为true，不相等为false。
    }*/

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Studnt studnt = (Studnt) o;
        return name.equals(studnt.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
